﻿using AgencyManagerSystem.Model;
using System.Collections.Generic;
using System.Linq;

namespace AgencyManagerSystem.DataFetcher
{
    public class DimensionDocFetcher : DetailFetcher<DimensionDocModel>
    {
        public override IList<DimensionDocModel> ListDetail(int mainId)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "Dimension", Op = "=", Value = mainId } };
            var list = List(conditions);
            return list;
        }

        public override IList<DimensionDocModel> ListDetail(int mainId, int pos, int size)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "Dimension", Op = "=", Value = mainId } };
            var list = List(conditions, pos, size);
            return list;
        }
        public virtual IList<DimensionDocModel> ListDimensionByProduction(int production,int level)
        {
            var productionFetcher = new ProductionFetcher();
            var productionModel = productionFetcher.Get(production);
            if (productionModel == null)
                return null;
            bool dimensionAvaliable = false;
            switch(level)
            {
                case 1:
                    dimensionAvaliable = productionModel.Dimension1;
                    break;
                case 2:
                    dimensionAvaliable = productionModel.Dimension2;
                    break;
                case 3:
                    dimensionAvaliable = productionModel.Dimension3;
                    break;
                case 4:
                    dimensionAvaliable = productionModel.Dimension4;
                    break;
                case 5:
                    dimensionAvaliable = productionModel.Dimension5;
                    break;
                case 6:
                    dimensionAvaliable = productionModel.Dimension6;
                    break;
                case 7:
                    dimensionAvaliable = productionModel.Dimension7;
                    break;
                case 8:
                    dimensionAvaliable = productionModel.Dimension8;
                    break;
                case 9:
                    dimensionAvaliable = productionModel.Dimension9;
                    break;
                case 10:
                    dimensionAvaliable = productionModel.Dimension10;
                    break;
            }
            var mainFetcher = new DimensionFetcher();
            var main = mainFetcher.GetByLevel(level);
            var details = ListDetail(main.AutoId);
            //var result = from item in details where item.Productions.Split(new char[] { ',' }).Contains(production.ToString()) select item;
            return details.ToList();
        }
    }
}
